#include <stdio.h>

/*c语言指针学习第3课：利用指针取最大最小值*/

void getMaxAndMin(int arr[],int len,int *max,int *min)
{
	//求数组最大值
	*max = arr[0];
	for (int i = 1; i<len; i++)
	{
		if (arr[i]>*max)
			*max = arr[i];
	}
	//求数组最小值
	*min = arr[0];
	for (int i = 1; i<len; i++)
	{
		if (arr[i]<*min)
			*min = arr[i];
	}
}

int main()
{
	int arr[] = {1,2,3,4,5,6,-7,8,9,0,13};
	int len = sizeof(arr) / sizeof (arr[0]);
	
	int max = arr[0];
	int min = arr[0];
	
	getMaxAndMin (arr,len,&max,&min);
	printf("数组最大值为：%d数组最小值为：%d。\n",max,min);

	return 0;
}